
package com.sms.servlet;

import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.io.IOException;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import com.sms.day_report.Day_report;
import com.sms.user.Student;

public class Day_reportser extends HttpServlet {

	/**
	 * 
	 */

	/**
	 * Constructor of the object.
	 */
	public Day_reportser() {
		super();
	}

	/**
	 * Destruction of the servlet. <br>
	 */
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	/**
	 * The doGet method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to get.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * The doPost method of the servlet. <br>
	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");

		//String status=request.getParameter("status");
		//if(status.equals("report_edit")){
		String fromid=(String) request.getSession().getAttribute("userno");
		System.out.println(fromid);
		Date now = new Date(); 
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//
		String reporttime = dateFormat.format( now );
		System.out.println(reporttime);
		String toid=request.getParameter("toname");
		System.out.println(toid);
		String content=request.getParameter("content");
		System.out.println(content);
		String sql="insert into personreport (fromid,toid,p_reporttime,content)values ("+fromid+","+toid+","+now+","+content+")";
		
       

	}
	//}
	/* Day_report report=new Day_report();
	 *System.out.print(report.query());   	
	 *List<Map> jlist=new ArrayList<Map> ();
	 *jlist=Day_report.query();
	 *System.out.println(jlist.size());
	 *JSONArray json = new JSONArray(); 
	 * for(int i=0;i<jlist.size();i++){
	 *	 Map map=jlist.get(i);
	 *	Day_report rep=new Day_report();   		
	 *	rep.init(map);
	 *	 JSONObject j=new JSONObject();
	 *	 j.put("p_reportid", rep.getP_reportId());
	 *	 j.put("Sname", rep.getSname(rep.getFromId()));
	 *	 j.put("stu_type", rep.getStype(rep.getFromId()));
	 *	 j.put("p_reporttime",rep.getP_reportTime());
	 *	 j.put("content", rep.getContent());
	 *	 json.add(j);
	 * }
	 * System.out.println(json.toString());

	 * }
	 */   


	/**
	 * Initialization of the servlet. <br>
	 *
	 * @throws ServletException if an error occurs
	 */
	public void init() throws ServletException {
		// Put your code here
	}

}
